package org.easybuy.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.easybuy.entity.BuyCar;
import org.easybuy.service.BuyCarService;
import org.easybuy.serviceimpol.BuyCarServiceImopl;

public class BuyCarServlet3 extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String userName = (String) request.getSession().getAttribute(
				"SHOW_USERNAME");
		BuyCarService buyCarServlet = new BuyCarServiceImopl();
		List<BuyCar> list = new ArrayList<BuyCar>();
		HttpSession session = request.getSession();
		list = buyCarServlet.getAllByUserName(userName);
		session.setAttribute("SHOU_ALL_BUYCAR", list);
		request.getRequestDispatcher("../BuyCar_Two.jsp")
				.forward(request, response);
	}
	
	
	
	

}
